// @flow
import { query } from "./utils/web" // 查询元素
import { mountComponent } from "./lifecycle" // 挂载组件
import Ken from "./main"

let uid = 0;
// 判断是否是在浏览器中
// 默认是在浏览器中
let inBrowser = true;

export function initMount(Ken: Ken) {
	Ken.prototype.$mount = function(
		el?: string, // | Element
		hydrating?: boolean
	) {
		el = el && inBrowser ? query(el) : ""; //fixme undefind
		return mountComponent(this, el, hydrating);
	}

	Ken.prototype._init = function(option?; Object){
		// 把传进来的数据挂载到了 $option 中
		const vm = this;
		// a uid
		vm._uid = uid++;
		vm.$option = options || {}
		if(vm.$option.el){
			vm.$mount(vm.$option.el);
		}
	}
}	